#include "ros/ros.h"
#include "geometry_msgs/Twist.h"

int main(int argc, char *argv[])
{
    if(argc != 3)
    {
        ROS_ERROR("Usage: demo1_topic_pub angular linear");
        return 1;
    }
    setlocale(LC_ALL, "");
    ros::init(argc, argv, "keyCtrl");
    ros::NodeHandle nh;

    // 创建发布实例
    ros::Publisher pub = nh.advertise<geometry_msgs::Twist>("/turtle1/cmd_vel", 10);
    // 设置发送频率
    ros::Rate rate(10);
    // 设置发布对象
    geometry_msgs::Twist tw;
    tw.angular.z = atof(argv[1]);
    tw.linear.x = atof(argv[2]);

    while(ros::ok())
    {
        pub.publish(tw);
        rate.sleep();
        ROS_INFO("发布的话题为：线速度--%lf 角速度--%lf", tw.linear.x, tw.angular.z);
        ros::spinOnce();
    }
    return 0;
}
